package com.ruoyi.system.util;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * 读取项目相关配置
 *
 * @author wdc

 */
@Component
@ConfigurationProperties(prefix = "ruoyi")
public class FilePathProperties {


    /**
     * 系统文件地址
     */
    private static String profile;



    public static String getProfile() {
        return profile;
    }

    public static void setProfile(String profile) {
        FilePathProperties.profile = profile;
    }




    /**
     * 获取临时文件存放地址
     */
    public static String getTemporaryFileSavePath() {
        File file = new File(getProfile() + File.separator + "Temporary");
        if (!file.exists()) file.mkdirs();
        return getProfile() + File.separator + "Temporary" + File.separator;
    }

    public static String getTpSavePath() {
      
        return  File.separator + "TP" + File.separator;
    }
//    1 图片 2 视频 3 影像 4 音频 5 矢量 6 地名数据 7 文档 8 zip
    public static String getSPSavePath() {

        return  File.separator + "SP" + File.separator;
    }

    public static String getYXSavePath() {

        return  File.separator + "YX" + File.separator;
    }

    public static String getYPSavePath() {

        return  File.separator + "YP" + File.separator;
    }

    public static String getSLSavePath() {

        return  File.separator + "SL" + File.separator;
    }

    public static String getDMSJSavePath() {

        return  File.separator + "DMSJ" + File.separator;
    }

    public static String getWDSavePath() {

        return  File.separator + "WD" + File.separator;
    }

    public static String getZIPSavePath() {
        return  File.separator + "zip" + File.separator;
    }



    /**
     * 获取文件存储地址
     *
     * @param code
     * @return java.lang.String
     */
    public static String getFileSavePath(Integer code) {
            if (code == SystemFileRelationDataTypeEnums.SP.getCode()) return getSPSavePath();
            if (code == SystemFileRelationDataTypeEnums.TP.getCode()) return getTpSavePath();
            if (code == SystemFileRelationDataTypeEnums.YX.getCode()) return getYXSavePath();
            if (code == SystemFileRelationDataTypeEnums.YP.getCode()) return getYPSavePath();
            if (code == SystemFileRelationDataTypeEnums.SL.getCode()) return getSLSavePath();
            if (code == SystemFileRelationDataTypeEnums.DMSJ.getCode()) return getDMSJSavePath();
            if (code == SystemFileRelationDataTypeEnums.WD.getCode()) return getWDSavePath();
            if (code == SystemFileRelationDataTypeEnums.ZIP.getCode()) return getZIPSavePath();
            if (code == SystemFileRelationDataTypeEnums.LSSJ.getCode()) return getTemporaryFileSavePath();

        return null;
    }

}
